diff options
| author | Fuwn <[email protected]> | 2026-03-01 16:04:11 -0800 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2026-03-01 16:04:11 -0800 |
| commit | 48f0c30d47d62e4f35706edb93a1bb2f97eba14c (patch) | |
| tree | 44866d7a61adfdf01a780e0108c370294d3db78b /src/routes/user/[user]/+page.svelte | |
| parent | chore(biome): re-enable useAltText rule (diff) | |
| download | due.moe-48f0c30d47d62e4f35706edb93a1bb2f97eba14c.tar.xz due.moe-48f0c30d47d62e4f35706edb93a1bb2f97eba14c.zip | |
chore(biome): enable svelte formatting
Diffstat (limited to 'src/routes/user/[user]/+page.svelte')
| -rw-r--r-- | src/routes/user/[user]/+page.svelte | 256 |
1 files changed, 128 insertions, 128 deletions
diff --git a/src/routes/user/[user]/+page.svelte b/src/routes/user/[user]/+page.svelte index 3c581c38..dd9d753e 100644 --- a/src/routes/user/[user]/+page.svelte +++ b/src/routes/user/[user]/+page.svelte @@ -1,36 +1,36 @@ <script lang="ts"> - import Spacer from '$lib/Layout/Spacer.svelte'; - import settings from '$stores/settings'; - import ParallaxImage from '../../../lib/Image/ParallaxImage.svelte'; - import { typeSchedule, type ParseResult } from '$lib/Hololive/hololive'; - import HeadTitle from '$lib/Home/HeadTitle.svelte'; - import Message from '$lib/Loading/Message.svelte'; - import { estimatedDayReading } from '$lib/Media/Manga/time'; - import Skeleton from '$lib/Loading/Skeleton.svelte'; - import root from '$lib/Utility/root'; - import locale from '$stores/locale'; - import { onMount } from 'svelte'; - import authorisedUsers from '$lib/Data/Static/authorised.json'; - import tooltip from '$lib/Tooltip/tooltip'; - import AnimeRateLimited from '$lib/Error/AnimeRateLimited.svelte'; - import identity from '$stores/identity'; - import SettingHint from '$lib/Settings/SettingHint.svelte'; - import proxy from '$lib/Utility/proxy'; - import { parseScheduleHtml } from '$lib/Data/hololive'; - import type { Preferences } from '../../../graphql/$types'; - import SvelteMarkdown from '@humanspeak/svelte-markdown'; - import MarkdownLink from '$lib/MarkdownLink.svelte'; - import LinkedTooltip from '$lib/Tooltip/LinkedTooltip.svelte'; - import { graphql } from '$houdini'; - - export let data; - - $: ({ Profile } = data); - $: preferences = $Profile.fetching - ? undefined - : ($Profile.data?.User?.preferences as Preferences | undefined); - - const setCategoriesQuery = graphql(` +import Spacer from '$lib/Layout/Spacer.svelte'; +import settings from '$stores/settings'; +import ParallaxImage from '../../../lib/Image/ParallaxImage.svelte'; +import { typeSchedule, type ParseResult } from '$lib/Hololive/hololive'; +import HeadTitle from '$lib/Home/HeadTitle.svelte'; +import Message from '$lib/Loading/Message.svelte'; +import { estimatedDayReading } from '$lib/Media/Manga/time'; +import Skeleton from '$lib/Loading/Skeleton.svelte'; +import root from '$lib/Utility/root'; +import locale from '$stores/locale'; +import { onMount } from 'svelte'; +import authorisedUsers from '$lib/Data/Static/authorised.json'; +import tooltip from '$lib/Tooltip/tooltip'; +import AnimeRateLimited from '$lib/Error/AnimeRateLimited.svelte'; +import identity from '$stores/identity'; +import SettingHint from '$lib/Settings/SettingHint.svelte'; +import proxy from '$lib/Utility/proxy'; +import { parseScheduleHtml } from '$lib/Data/hololive'; +import type { Preferences } from '../../../graphql/$types'; +import SvelteMarkdown from '@humanspeak/svelte-markdown'; +import MarkdownLink from '$lib/MarkdownLink.svelte'; +import LinkedTooltip from '$lib/Tooltip/LinkedTooltip.svelte'; +import { graphql } from '$houdini'; + +export let data; + +$: ({ Profile } = data); +$: preferences = $Profile.fetching + ? undefined + : ($Profile.data?.User?.preferences as Preferences | undefined); + +const setCategoriesQuery = graphql(` mutation SetCategories($categories: [String!]!) { setPinnedBadgeWallCategories(categories: $categories) { id @@ -42,7 +42,7 @@ } `); - const toggleCategoryQuery = graphql(` +const toggleCategoryQuery = graphql(` mutation ToggleCategory($category: String!) { togglePinnedBadgeWallCategory(category: $category) { id @@ -54,7 +54,7 @@ } `); - const toggleHideMissingBadgesQuery = graphql(` +const toggleHideMissingBadgesQuery = graphql(` mutation ToggleHideMissingBadges { toggleHideMissingBadges { id @@ -66,7 +66,7 @@ } `); - const toggleHideAWCBadgesQuery = graphql(` +const toggleHideAWCBadgesQuery = graphql(` mutation ToggleHideAWCBadges { toggleHideAWCBadges { id @@ -78,7 +78,7 @@ } `); - const setBiographyQuery = graphql(` +const setBiographyQuery = graphql(` mutation SetBiography($biography: String!) { setBiography(biography: $biography) { id @@ -90,7 +90,7 @@ } `); - const setBadgeWallCSSQuery = graphql(` +const setBadgeWallCSSQuery = graphql(` mutation SetBadgeWallCSS($css: String!) { setBadgeWallCSS(css: $css) { id @@ -102,121 +102,121 @@ } `); - $: userData = data.userData; +$: userData = data.userData; - let error = false; - let schedule: ParseResult | undefined = undefined; - let draggedCategory: string | null = null; - let draggedOverCategory: string | null = null; +let error = false; +let schedule: ParseResult | undefined = undefined; +let draggedCategory: string | null = null; +let draggedOverCategory: string | null = null; - $: displayBadges = (username: string, badges: number | string) => - $locale({ - values: { - badges: badges, - username - } - }).user.profile.badges; - - const handleDragStart = ( - event: DragEvent & { currentTarget: EventTarget & HTMLDivElement }, - category: string | null - ) => { - draggedCategory = category; - - if (event.dataTransfer) event.dataTransfer.effectAllowed = 'move'; - }; +$: displayBadges = (username: string, badges: number | string) => + $locale({ + values: { + badges: badges, + username + } + }).user.profile.badges; - const handleDragOver = (event: DragEvent) => { - event.preventDefault(); +const handleDragStart = ( + event: DragEvent & { currentTarget: EventTarget & HTMLDivElement }, + category: string | null +) => { + draggedCategory = category; - if (event.dataTransfer) event.dataTransfer.dropEffect = 'move'; - }; + if (event.dataTransfer) event.dataTransfer.effectAllowed = 'move'; +}; - const handleDragEnter = ( - event: DragEvent & { currentTarget: EventTarget & HTMLDivElement }, - category: string | null - ) => { - event.preventDefault(); +const handleDragOver = (event: DragEvent) => { + event.preventDefault(); - if (draggedCategory !== category && preferences && draggedCategory) { - draggedOverCategory = category; + if (event.dataTransfer) event.dataTransfer.dropEffect = 'move'; +}; - const categories = preferences.pinned_badge_wall_categories; - const draggedIndex = categories.indexOf(draggedCategory); - const targetIndex = categories.indexOf(category || ''); +const handleDragEnter = ( + event: DragEvent & { currentTarget: EventTarget & HTMLDivElement }, + category: string | null +) => { + event.preventDefault(); - categories.splice(draggedIndex, 1); - categories.splice(targetIndex, 0, draggedCategory); + if (draggedCategory !== category && preferences && draggedCategory) { + draggedOverCategory = category; - preferences.pinned_badge_wall_categories = categories; - } - }; + const categories = preferences.pinned_badge_wall_categories; + const draggedIndex = categories.indexOf(draggedCategory); + const targetIndex = categories.indexOf(category || ''); - const handleDragLeave = ( - event: DragEvent & { currentTarget: EventTarget & HTMLDivElement }, - category: string - ) => { - event.preventDefault(); + categories.splice(draggedIndex, 1); + categories.splice(targetIndex, 0, draggedCategory); - if (draggedOverCategory === category && preferences && draggedCategory) { - draggedOverCategory = null; + preferences.pinned_badge_wall_categories = categories; + } +}; - const categories = preferences.pinned_badge_wall_categories; - const draggedIndex = categories.indexOf(draggedCategory); +const handleDragLeave = ( + event: DragEvent & { currentTarget: EventTarget & HTMLDivElement }, + category: string +) => { + event.preventDefault(); - categories.splice(draggedIndex, 1); - categories.splice(categories.indexOf(category) + 1, 0, draggedCategory); + if (draggedOverCategory === category && preferences && draggedCategory) { + draggedOverCategory = null; - preferences.pinned_badge_wall_categories = categories; - } - }; + const categories = preferences.pinned_badge_wall_categories; + const draggedIndex = categories.indexOf(draggedCategory); - const handleDrop = (event: { preventDefault: () => void }) => { - event.preventDefault(); + categories.splice(draggedIndex, 1); + categories.splice(categories.indexOf(category) + 1, 0, draggedCategory); - if (userData && preferences) - setCategoriesQuery - .mutate({ - categories: preferences.pinned_badge_wall_categories + preferences.pinned_badge_wall_categories = categories; + } +}; + +const handleDrop = (event: { preventDefault: () => void }) => { + event.preventDefault(); + + if (userData && preferences) + setCategoriesQuery + .mutate({ + categories: preferences.pinned_badge_wall_categories + }) + .then(); + + draggedCategory = null; + draggedOverCategory = null; +}; + +onMount(async () => { + schedule = typeSchedule( + parseScheduleHtml( + await ( + await fetch(proxy('https://schedule.hololive.tv'), { + headers: { + Cookie: 'timezone=Asia/Tokyo' + } }) - .then(); - - draggedCategory = null; - draggedOverCategory = null; - }; - - onMount(async () => { - schedule = typeSchedule( - parseScheduleHtml( - await ( - await fetch(proxy('https://schedule.hololive.tv'), { - headers: { - Cookie: 'timezone=Asia/Tokyo' - } - }) - ).text() - ) - ); - }); + ).text() + ) + ); +}); - const getBadgeWallCSS = () => - (document.getElementById('badgeWallCSS') as HTMLTextAreaElement).value; +const getBadgeWallCSS = () => + (document.getElementById('badgeWallCSS') as HTMLTextAreaElement).value; - const getBiography = () => - (document.getElementById('biography') as HTMLTextAreaElement).value.slice(0, 3000); +const getBiography = () => + (document.getElementById('biography') as HTMLTextAreaElement).value.slice(0, 3000); - const toggleCategory = () => { - if (!userData) return; +const toggleCategory = () => { + if (!userData) return; - const categoryElement = document.getElementById('category') as HTMLInputElement; - const category = categoryElement.value; + const categoryElement = document.getElementById('category') as HTMLInputElement; + const category = categoryElement.value; - toggleCategoryQuery.mutate({ category }).then(); + toggleCategoryQuery.mutate({ category }).then(); - categoryElement.value = ''; - }; + categoryElement.value = ''; +}; - // 8.5827814569536423841e0 +// 8.5827814569536423841e0 </script> <HeadTitle route={`${data.username}'s Profile`} path={`/user/${data.username}`} /> |